package com.qf.controller;

import com.qf.pojo.TCheckgroup;
import com.qf.service.TCheckgroupService;
import com.qf.service.TCheckitemService;
import com.qf.utils.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class CheckgroupController {
    private final TCheckgroupService checkgroupService;
    private final TCheckitemService checkitemService;
    @GetMapping("/checkgroup/findPage")
    public Result findCheckgroupPage(@RequestParam(value = "currentPage",defaultValue = "1")int page,
                                     @RequestParam(value = "pageSize",defaultValue = "10") int pageSize,
                                     @RequestParam(value = "queryString",defaultValue = "") String queryString){
        return checkgroupService.findCheckgroupPage(page,pageSize,queryString);
    }

    @GetMapping("/checkgroup/findById")
    public Result findById(@RequestParam(value = "id") int id){
        return checkgroupService.findById(id);
    }
    @GetMapping("/checkitem/findAll")
    public Result findAllCheckitem(){
        return checkitemService.findAll();
    }

    @GetMapping("/checkgroup/findCheckItemIdsByCheckGroupId")
    public Result findCheckItemIdsByCheckGroupId(@RequestParam("id") long id){
        return checkgroupService.findCheckItemIdsByCheckGroupId(id);
    }

    @PostMapping("/checkgroup/edit")
    public Result edit( Integer[] checkitemIds,
                        @RequestBody  TCheckgroup checkgroup){
        return checkgroupService.edit(checkitemIds,checkgroup);
    }
    @PostMapping("/checkgroup/add")
    public Result add(Integer[] checkitemIds,
                       @RequestBody TCheckgroup checkgroup){
        return checkgroupService.add(checkitemIds,checkgroup);
    }

    @PostMapping("/checkgroup/delete")
    public Result delete(@RequestParam("id") long id){
        return checkgroupService.delete(id);
    }
}
